#include "Col.ph"
#ifdef __GNUG__
#pragma implementation
#endif

#include "Interpreter.h"
#include "Class.h"
#include "ClassManager.h"
#include "String.h"
#include "OrdColl.h"

//---- Interpreter -------------------------------------------------------------

NewMetaImpl0(Interpreter,Object);

Interpreter::Interpreter(const char *type)
{
	Iter next(gClassManager->Iterator());
	Class *cla;

	while (cla= (Class*)next()) {
		if (cla->isKindOf(Meta(InterpreterImpl))
					&& strcmp(cla->Name(), type) == 0) {
			impl= (InterpreterImpl*) cla->Proto()->New();
			break;
		}
	}
	if (impl == 0)
		impl= new InterpreterImpl;
	impl->SetInterpreter(this);
}

Interpreter::~Interpreter()
{
	SafeDelete(impl);
}

//---- InterpreterImpl ---------------------------------------------------------

NewMetaImpl0(InterpreterImpl,Object);

InterpreterImpl::InterpreterImpl()
{
	interp= 0;
}

InterpreterImpl::~InterpreterImpl()
{
	interp= 0;
}

int InterpreterImpl::Eval(const char*)
{
	AbstractMethod("Eval");
	return -1;
}

void InterpreterImpl::SetResult(const char*, bool)
{
	AbstractMethod("SetResult");
}

const char *InterpreterImpl::GetResult()
{
	AbstractMethod("GetResult");
	return 0;
}

int InterpreterImpl::InstallCommand(const char*, IntCmdProc*, void*)
{
	AbstractMethod("InstallCommand");
	return -1;
}

int InterpreterImpl::LoadSourceFile(const char*)
{
	AbstractMethod("LoadSourceFile");
	return -1;
}

